package com.imu.purse.modules.app.dao;

import java.util.List;
import org.apache.ibatis.annotations.Select;
import com.imu.purse.modules.app.entity.ImuUserInvEntity;
import com.imu.core.base.BaseMapper;

/**
 * 用户推荐邀请
 * @author sunhongwei
 * @email sunhongwei@jshijian.com
 * @date 2018-03-21 11:11:59
 * Copyright (c) 2017 武汉极时间科技有限公司 版权所有 
 * Jshijian aloha CO.,LTD. All Rights Reserved. 
 */
public interface ImuUserInvMapper extends BaseMapper<ImuUserInvEntity>
{
	/**
     * 分页查询
     * @param pageNo 页号
     * @param pageSize 每页显示记录数
     * @return
     */
	@Select({
		"<script>",
		    "SELECT id,",
					"user_id, ",
					"user_inv_id, ",
					"time_create, ",
					"user_update, ",
					"time_update",
		    "FROM imu_user_inv ",
		    "WHERE status != -1",
			"<when test = 'userId != null'>",
		    	"AND `user_id` = #{userId}",
		    "</when>",
			"<when test = 'userInvId != null'>",
		    	"AND `user_inv_id` = #{userInvId}",
		    "</when>",
			"<when test = 'timeCreate != null'>",
		    	"AND `time_create` = #{timeCreate}",
		    "</when>",
			"<when test = 'userUpdate != null'>",
		    	"AND `user_update` = #{userUpdate}",
		    "</when>",
			"<when test = 'timeUpdate != null'>",
		    	"AND `time_update` = #{timeUpdate}",
		    "</when>",
		    "<when test = 'stimeStr != null'>",
		    	"AND cs &gt;= #{stimeStr}",
		    "</when>",
		    "<when test = 'etimeStr != null'>",
				"AND cs &lt;= #{etimeStr}",
			"</when>",
		    "ORDER BY cs DESC",
    	"</script>"
	})
    public List<ImuUserInvEntity> findByPage(final ImuUserInvEntity entity);
	
}
